Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update useParticipants to listen for any Participant's info changes #980

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

lebaudantoine
Copy link
Contributor

Issue

This is my first contribution! I’d love any advice on how to contribute to the repo. While working with the useParticipants hook, I expected it to keep the participants list updated with their names. However, I found that useParticipants only listens to metadata changes by default and does not react to updates in names or attributes.

To ensure the participants list updates correctly, I called the hook as follows:

const participants = useParticipants({
  updateOnlyOn: [
    RoomEvent.ParticipantNameChanged,
    ...allParticipantRoomEvents,
  ],
});

Additionally, I noticed that the term updateOnlyOn could be misleading, as it always includes three events. While the documentation clarifies this, it may cause confusion when reading the code.

Solution

I found the previous implementation a bit convoluted. I propose that useParticipants should update on all room events that trigger state changes for a participant, as originally intended by @Ocupe. Additionally, please note that a few events related to end-to-end encryption and permissions are still missing from the current setup.

Copy link

changeset-bot bot commented Sep 20, 2024

🦋 Changeset detected

Latest commit: b3ec185

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@livekit/components-core Patch
@livekit/components-react Patch
@livekit/component-example-next Patch
@livekit/components-js-docs Patch
@livekit/component-docs-storybook Patch
@livekit/components-docs-gen Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lebaudantoine lebaudantoine marked this pull request as draft September 20, 2024 09:13
@lebaudantoine lebaudantoine marked this pull request as ready for review September 20, 2024 09:19
@lebaudantoine
Copy link
Contributor Author

what do you think @lukasIO?

@lukasIO
Copy link
Contributor

lukasIO commented Sep 23, 2024

Thanks for catching this! We missed to update those events in the event group.

@@ -0,0 +1,5 @@
---
'@livekit/components-core': minor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'@livekit/components-core': minor
'@livekit/components-core': patch

as it's primarily a bugfix, I think we should mark it as a patch update

Copy link
Contributor Author

@lebaudantoine lebaudantoine Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, ready for merge @lukasIO !

@lukasIO
Copy link
Contributor

lukasIO commented Sep 23, 2024

@lebaudantoine feel free to open a subsequent PRs for the other missing events, we'd definitely want them to be part of allRemoteParticipantEvents as well!

Extended allRemoteParticipantRoomEvents to include participant state events,
aligning with @Ocupe's original intent in livekit#306: covering "all room events that
trigger state changes on a participant by default."

Since both name and metadata are treated as participant info in some observers,
it makes sense to include these events. Name changes won’t cause frequent
re-renders, but attributes might.

This raises larger questions:

Does the current naming accurately reflect that not
all remote participant events are covered?

Should participantInfoObserver also track attributes,
if we consider them part of the participant's information?

Feedback and edits are more than welcome
@lukasIO lukasIO merged commit 3a8495f into livekit:main Sep 26, 2024
2 checks passed
@github-actions github-actions bot mentioned this pull request Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants